angular.module('starter.directives', [])
  .directive('backImg', function(){
    return function(scope, element, attrs){
      var url = attrs.backImg;
      element.css({
        'background': 'url(' + url +')',
        'background-size' : '100% 100%',
        'background-repeat':'no-repeat'
      });
    };})

.directive('rjCloseBackDrop', [function() {
    return {
      scope: false,//共享父scope
      restrict: 'A',
      replace: false,
      link: function(scope, iElm, iAttrs, controller) {
        //要在html上添加点击事件, 试了很久- -!
        var htmlEl = angular.element(document.querySelector('html'));
        htmlEl.on("click", function(event) {
          if (event.target.nodeName === "HTML" &&
            scope.popup.optionsPopup &&
            scope.popup.isPopup) {
            scope.popup.optionsPopup.close();
            scope.popup.isPopup = false;
          }
        });
      }
    };
  }]);
;
